class Solution:
    def isBalanced(self, num: str) -> bool:
        sm, size = 0, len(num)
        for i in range(0, size, 2):
            sm += int(num[i]) - (int(num[i + 1]) if i + 1 < size else 0)
        return sm == 0


class Solution:
    def isBalanced(self, num: str) -> bool:
        return sum(int(num[i]) - (int(num[i + 1]) if i + 1 < len(num) else 0) for i in range(0, len(num), 2)) == 0
